package com.xiaojf.xsso.sample.web.controller;

import com.xiaojf.xsso.common.constant.SsoConstant;
import com.xiaojf.xsso.common.model.CommonResult;
import com.xiaojf.xsso.common.model.SsoUser;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 首页
 *
 * @author Ade.Xiao 2021/1/29 15:14
 */
@Controller
public class IndexController {
    /**
     * 测试接口， 返回json字符串
     *
     * @param request
     * @return {@link CommonResult< SsoUser>}
     * @author Ade.Xiao 2021-03-12 09:49:17
     */
    @RequestMapping("/")
    @ResponseBody
    public CommonResult<SsoUser> index(HttpServletRequest request) {
        SsoUser ssoUser = (SsoUser) request.getAttribute(SsoConstant.SSO_USER);
        return new CommonResult(ssoUser);
    }

}